package com.codemonkey.lq.extend.spring;

import org.springframework.util.StopWatch;

public final class StopWatchHelper {
	/**
	 * 返回值以秒为单位
	 * @return
	 */
	public double time(Action action) {
		StopWatch stopWatch = new StopWatch();
		stopWatch.start();

		// 执行实际的逻辑
		action.execute();

		stopWatch.stop();
		return stopWatch.getTotalTimeSeconds();
	}

	public static interface Action {
		void execute();
	}
}
